package com.lam.mall.mapStruct;

import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;

import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.ReportingPolicy;
import org.mapstruct.factory.Mappers;

import com.lam.common.utils.CollectionUtil;
import com.lam.mall.app.vo.HotSearchVo;
import com.lam.mall.entity.HotSearch;

@Mapper(unmappedTargetPolicy = ReportingPolicy.IGNORE)
public interface HotSearchConvert {

	HotSearchConvert instance = Mappers.getMapper(HotSearchConvert.class);
	
	@Mapping(source = "id", target = "hotSearchId")
	HotSearchVo toVo(HotSearch entity);
	
	default List<HotSearchVo> toVo(List<HotSearch> list){
		if(CollectionUtil.isEmpty(list)) {
			return Collections.emptyList();
		}
		return list.stream().map(t->toVo(t)).collect(Collectors.toList());
	}

}
